#ifndef MEMORYITEMMODEL_H
#define MEMORYITEMMODEL_H

#include <QAbstractTableModel>

class BreakPointTable;
class MemoryWidget;
class Memory;
class CPU;

class MemoryItemModel : public QAbstractTableModel
{
    Q_OBJECT

public:
    static const quint32 NUMBER_PER_PAGE;
    static const quint32 NUMBER_OF_PAGE;

public:
    MemoryItemModel(MemoryWidget* _widget, QObject *parent = 0);
    virtual ~MemoryItemModel();
    //
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant data(const QModelIndex &index, int role) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    bool setData(const QModelIndex &index, const QVariant &value, int role);
    //
    void setPageIndex(quint32 index);
    quint32 getBaseAddress() const;

public slots:
    void changeBreakPoint(const QModelIndex& index);

private slots:
    void updateMemory(quint32 address);
    void updatePC(int id);

private:
    MemoryWidget* widget;
    Memory* memory;
    CPU* cpu;
    BreakPointTable* breakTable;
    quint32 baseAddress;
    quint32 pageIndex;
    quint32 lastPCIndex;
};

#endif // MEMORYITEMMODEL_H
